<?php

/**
 * Photo form.
 *
 * @package    sanziniafilms
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class PhotoForm extends BasePhotoForm
{
  public function configure()
  {
  
	parent::configure();
	$this->useFields(array('imagen', 'tree_id',  'titulo', 'favorito'));
    $this->widgetSchema['imagen'] = new sfWidgetFormInputFileEditable(array(
      'label'     => 'Foto',
      'file_src'  => '/uploads/assets/'.$this->getObject()->getImagen(),
      'is_image'  => true,
      'edit_mode' => !$this->isNew(),
	  'with_delete' => false,
   ));
   
  $this->widgetSchema['tree_id'] = new sfWidgetFormInputHidden();
  $this->widgetSchema['favorito'] = new sfWidgetFormInputHidden();
  $this->setDefault("tree_id", sfContext::getInstance()->getRequest()->getParameter('idAlbum') );
  
  
	// Uncomment the following line if you want to make the directory if it doesn't exist
	if (!file_exists(sfConfig::get('sf_upload_dir').'/assets/thumbs/')) {
		mkdir(str_replace('//','/',sfConfig::get('sf_upload_dir').'/assets/thumbs/'), 0755, true);
	}

	$this->validatorSchema['imagen'] = new sfValidatorFile(array(
      'required'   => false,
      'path'       => sfConfig::get('sf_upload_dir').'/assets/',
      'mime_types' => 'web_images',
	  'validated_file_class' => 'MyValidatedFile',
    ));
	
	unset($this['created_at'], $this['updated_at']);
  }
}
